home *** CD-ROM | disk | FTP | other *** search
/ Developer Helper 1: Phil & Dave's Excellent CD / Excellent CD HFS.raw / Moof / Goodies / HyperCard Goodies / Serial Toolkit / Source Code / charsAvailable.p < prev    next >
Text File  |  1988-11-18  |  1KB  |  67 lines

  1. (*
  2.     charsAvailable() -- Return the number of characters available for reading from the serial port.
  3.  
  4.     To compile and link this file using Macintosh Programmer's Workshop,
  5.  
  6.         pascal -w charsAvailable.p
  7.         link -m ENTRYPOINT -o HyperCommands -rt XFCN=7030 -sn Main=charsAvailable ∂
  8.             charsAvailable.p.o "{MPW}"Libraries:interface.o
  9.  
  10.     © Copyright 1987,88 by Apple Computer, Inc.
  11.  
  12.     Initial coding 9/87 by Harry R. Chesley.
  13. *)
  14.  
  15. {$R-}
  16.  
  17. {$S charsAvailable }     { Segment name must be the same as the command name. }
  18.  
  19. unit DummyUnit;
  20.  
  21. interface
  22.  
  23. uses MemTypes, QuickDraw, OSIntf, HyperXCmd;
  24.  
  25. procedure EntryPoint(paramPtr: XCmdPtr);
  26.     
  27. implementation
  28.  
  29. type
  30.  
  31. Str31 = String[31];
  32.  
  33. procedure charsAvailable(paramPtr: XCmdPtr); forward;
  34.  
  35. procedure EntryPoint(paramPtr: XCmdPtr);
  36.  
  37.     begin
  38.         charsAvailable(paramPtr);
  39.     end;
  40.  
  41. procedure charsAvailable(paramPtr: XCmdPtr);
  42.  
  43.     var l: longInt;
  44.  
  45.     {$I XCmdGlue.inc}
  46.  
  47.     procedure Fail(errMsg: Str255); { set theResult and quit }
  48.         begin
  49.             paramPtr^.returnValue := PasToZero(errMsg);
  50.             exit(charsAvailable);
  51.         end;
  52.  
  53.     {$I SPortUtil.inc}
  54.  
  55.     begin
  56.         if paramPtr^.paramCount <> 0 then Fail('parameter count is not 0');
  57.  
  58.         SetUpSPortGlobals;
  59.         EnsureOpenPort;
  60.  
  61.         { Get and return the character count from the port. }
  62.         if SerGetBuf(ThisSPort.portInDev,l) <> noErr then Fail('SerGetBuf failed');
  63.         paramPtr^.returnValue := PasToZero(LongToStr(l))
  64.     end;
  65.  
  66. end.
  67.